#include<bits/stdc++.h>
using namespace std;
const int N=310,mod=1e9+7;
int n,m;
char a[N][N];
int solve(){
    int ans=1;
    for(int i=1;i<=m;i++)
        if(a[1][i]==a[1][i+1])ans=ans*2%mod;
    return ans;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    freopen("disanti.in","r",stdin);
    freopen("disanti.out","w",stdout);
    cin>>n>>m;
    for(int i=1;i<=n;i++)cin>>a[i]+1;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            a[i][j]='0'+'1'-a[i][j];
            cout<<solve()<<' ';
            a[i][j]='0'+'1'-a[i][j];
        }
        cout<<'\n';
    }
    return 0;
}
